'use strict';
var app = (function() {
	var _private = {	
		subs : {}
	};
	return {
		subscribe : function(el, name, cb) {
			if (!_private.subs[name]) {
				_private.subs[name] = [];
			}
			_private.subs[name].push([el, cb]);
			return name;
		}, 
		unsubscribe : function(name) {
			for ( var sub in _private.subs ) {
	            if ( _private.subs[sub] ) {
	                for (var i = 0, j = _private.subs[sub].length; i < j; i++) {
	                    if (_private.subs[sub][i].el === token) {
	                        topics[m].splice(i, 1);
	                        return token;
	                    }
	                }
	            }
	        }
	        return false;
		},
		publish : function(name, data) {
			data = [data] || [];
			for (var i = 0, y = _private.subs[name].length; i < y; i++)
			{
				try {
					_private.subs[name][i][1].apply(_private.subs[name][i][0], data);
				}
				catch (ex) {
					if (console) {
						console.log("Error handled:", ex);
					}
				}
			}
		}
	}		
})(); 
// higginsforpresident.net/js/static/jq.pubsub.js
// app.subscribe($(this), "newMessages", callback);
// app.publish("newMessages", data);
// app.unsubscribe($(this), "newMessages");